package threads;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Package: threads
 * Description： TODO
 * Author: Forest
 * Date: Created in 2021/4/8 14:16
 * Version: 0.0.1
 * Modified By: duforest
 */
public class ThreadExceptionRunner implements Runnable {

    private AtomicBoolean atomicBoolean;

    public ThreadExceptionRunner(AtomicBoolean atomicBoolean) {
        this.atomicBoolean = atomicBoolean;
    }

    @Override
    public void run() {
//        atomicBoolean.set(false);
        System.out.println("current thread name=" + Thread.currentThread().getName());
        try {
            int i = 3 / 0;
        } catch (Exception e) {
            System.out.println(e);
            atomicBoolean.set(false);
        }
//        int i = 3 / 0;

        // 继续后续处理
        for (int j = 0; j < 10; j++) {
            System.out.println(String.format("continue do something,i={%s}",j));
        }
    }


}
